part of pp_net;

enum PPRequestMethod {
  GET,
  POST,
  PUT,
}

class PPReq<T> {
  PPReq({
    required this.path,
    this.parameters,
    this.data,
    this.method = PPRequestMethod.POST,
    this.headers,
    this.retries = 0,
    this.retryDelay = const Duration(seconds: 2),
  });

  /// 请求路径，如果 `path` 以 "http(s)"开始, 则 `baseURL` 会被忽略； 否则,
  /// 将会和baseUrl拼接出完整的的url.
  late String path;

  /// query parameters
  Map<String, dynamic>? parameters;

  dynamic data;

  /// Http method.
  late PPRequestMethod method = PPRequestMethod.POST;

  /// Http请求头.
  Map<String, dynamic>? headers;

  /// 最大重试次数
  int retries;

  /// 重试间隔
  Duration retryDelay;

  get reqTag {
    return path;
  }
}
